A silicon integrated system or System on a Chip (SoC) includes at least a central processing unit (CPU) on which programs can be run, a direct memory access controller (DMA controller), a memory and a memory management unit (MMU). Such SoCs are typically included in electronic devices such as general purpose computers, decoder units or “Set-Top-Boxes”, personal digital assistants or PDAs, mobile phones, etc.
In physical memory, a variable size memory space is dynamically allocated to each application program or user program. More specifically, each user program has access to only some of the pages of physical memory. These pages form a memory space (which may be discontinuous) which is addressed at memory bus level by physical addresses, but which is known to the user program via an address space (normally continuous) called a virtual address space which the program accesses with virtual addresses. The virtual address space is specific to the user program. The relationship that links the virtual addresses in the address space and the physical addresses in physical memory is stored in the form of a translation table, called a page table, which is managed by the operating system and stored in main memory. The latest address translations computed by the MMU table reloading unit are stored in a specific cache memory called a TLB (Translation Look-aside Buffer).
Each entry of the TLB, that is, each line corresponding to a translation in the TLB, comprises an address space identifier (ASID) to distinguish identical virtual addresses in different address spaces. Each ASID is linked, on a one-to-one basis, to a defined address space of the system.
The DMA controller performs data transfers between the internal memory of the SoC and peripheral memory devices (for example, hard disks) based on information supplied to it. This information comprises the source physical address of the transfer, the destination physical address of the transfer and the size of the memory area to be transferred.
Conventionally, a program requiring programming of the DMA controller for a DMA transfer running on the SoC in user mode (also called application mode or non-privileged mode) supplies a virtual address, which is the virtual address of the source of the DMA transfer or the destination of the DMA transfer, to the operating system or OS. The OS, running in privileged mode (also called supervisor mode or kernel mode) then takes control, translates the supplied virtual address into a corresponding physical address. It requires in turn storage of the source physical address of the transfer obtained in the source register, storage of the destination address in the destination register and storage of the size in the size register, and this from the virtual address of the registers. The OS then supervises the transfer performed by the DMA controller based on the information stored in its registers and notifies the program initiating the request of the result of the transfer.
The store instructions normally used are of the type: “STORE pa_src@dma_src_reg_adr”, “STORE pa_dest@dma_dest_reg_adr” and “STORE size@dma_size_reg_adr”, in which “pa_src” is the source physical address, “pa_dest” is the destination physical address, “size” is the size of the memory area transferred, “dma_src_reg_adr”, “dma_dest_reg_adr” and “dma_size_reg_adr” are respectively the virtual addresses of the source, destination and size registers. The first instruction above in plain language means “store the data corresponding to the source physical address “pa_src” in the source address register of the DMA controller whose virtual address is “dma_src_reg_adr””. This instruction therefore supplies a virtual address argument “dma_src_reg_adr” and a data argument “pa_src” to be stored at the address supplied as an address argument.
With reference to FIG. 1 which shows an example of a conventional SoC, the conventional programming path for the DMA controller is as follows: the virtual address “dma_src_reg_adr” is supplied by the CPU to the MMU over the virtual address bus VA. The MMU translates it into a physical address, checks the rights of access to this physical address, then applies it to the physical address bus PA, via which it is made available in particular to the DMA controller on the general bus A which is linked to a set of entities comprising, for example, disk controllers, physical memory, etc.
In parallel, the source physical address “pa_src” is applied by the CPU to the data bus DAT, from which it is made available on the general data bus D, also linked to the set of entities.
The source address and the address of the source register are respectively applied to the general data bus D and to the general address bus A according to the protocol adopted for bus management. According to the bus management protocols, the physical address of the source register is applied, for example, to the general address bus A virtually at the same time as the source physical address “pa_src” is applied to the general data bus D, or the address of the source register is positioned on the general address bus A one clock pulse before the source physical address is positioned on the general data bus D (for a protocol in which the addresses are positioned one clock pulse before the corresponding data), or even one of the addresses is applied on the rising edge whereas the other is applied on the falling edge, and so on.
The translation is performed by the MMU using a translation table.
A number of attempts have recently been made to program the DMA controller directly by a program running in user mode, instead of by the OS. This stems in particular from the very high proportion of time required for the programming of a DMA controller by the OS, compared to the data transfer time itself that is achieved by the DMA controller.
One of the difficulties encountered originates from the fact that the registers of the DMA controller must be programmed with physical addresses, whereas the programs in user mode do not have access to them and it is not desirable, particularly for security reasons, for them to have access to them.
Various solutions are proposed in the documents “User-Level DMA without Operating System Kernel Modification”, by Evangelos P. Markatos and Manolis G. H. Katevenis (Institute of Computer Science, Science and Technology Park of Crete, 1997 IEEE), “Protected User-Level DMA for the Shrimp Network Interface”, by M. A. Blumrich et al. (Proc. of the 2nd International Symposium on High Performance Computer Architecture, pages 154-165, February 1996) and “Integration of Message Passing and Shared Memory in the Stanford Flash Multi-Processor”, by J. Heinlein et al. (Proc. of the 6th International Conference on Architectural Support for Programming Languages and Operating Systems, pages 38-50, 1994).
According to these solutions, implicit addressing (or “shadow addressing”) is performed, based on the “STORE” instruction and the prefix 1. The drawback of these solutions is that the addressable memory space in practice is reduced by half, which is very detrimental.
Other solutions are described in French Patent Application No. 04 06666 (STMicroelectronics) which offer the advantage of wasting far less addressable memory space than the solutions described above.
The solutions explained in French Patent Application No. 04 07763, filed on Jul. 12, 2004, and French Patent Application No. 04 08084, filed on Jul. 21, 2004, (STMicroelectronics) do not incur any waste of addressable memory space in practice.
In the conventional systems on a chip where the programming of the DMA controller was driven by the OS, management of the discontinuities in the physical memory space is managed by software, directly by the OS running in privileged mode. Since the OS has access to the physical addresses, this management does not pose any particular problems.
When two memory areas are indicated by two consecutive virtual addresses corresponding to two physical addresses that are not consecutive, there is a discontinuity between these two memory areas in the physical memory space.
The discontinuities appear exclusively in the physical memory space. There is no discontinuity in the virtual address space.
In some of these systems on a chip, the OS programs the DMA controller to perform individual transfers which take place on linear pieces of memory without discontinuity. At the end of each individual transfer, the DMA controller generates an interrupt to indicate the end of the transfer. The OS then programs it with a new linear piece of memory and so on until all of the memory area to be transferred, defined by an application originating from the overall transfer, has been transferred. When the final individual transfer is finished, the DMA controller sends an interrupt to the OS which then informs the application that the transfer is completed.
In certain other of these known systems on a chip, the OS scans a page table of the physical memory space, generates chained lists indicating the discontinuities and, on DMA programming, supplies the relevant chained list to the DMA controller, which was designed to then be programmed according to this chained list (“scatter gather” mechanism) without the intervention of the OS.
Such techniques are described for example in U.S. Pat. No. 5,708,849 (Coke et al.) and EP 0 589 664 (IBM).
In the techniques indicated above that enable the DMA controller to be programmed directly by a program running in user mode, and no longer by the OS, it is no longer possible to implement the conventional solutions to manage the discontinuities, since the OS is no longer invoked for the programming and the user program sees only a linear virtual memory space.